﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using mal.balades.Business.DataModel;

namespace mal.balades.Business.Web
{
    public static class UrlManager
    {
        private static bool UseUrlRouting
        {
            get
            {
                bool useUrlRouting=false;
                bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["UseUrlRouting"], out useUrlRouting);
                return useUrlRouting;

            }
        }

        public static string CategoryUrl(object url)
        {
            if(UseUrlRouting)
                return string.Concat("/Visites/", url);
            else
                return string.Concat("/Views/VisitsList.aspx?catUrl=", url);
        }


        public static string VisitUrl(object url)
        {
            if (UseUrlRouting)
             return string.Concat("/Visites/", url);
            else
                return string.Concat("/Views/VisitView.aspx?VisitCatUrl=", url);
        }

        public static string VisitUrl(Visit visit)
        {
            if (UseUrlRouting)
                return string.Format("/Visites/{0}/{1}", visit.PlaceCategory.UrlName,visit.UrlName);
            else
                return string.Concat("/Views/VisitView.aspx?VisitUrl=", visit.UrlName);
        }

        public static string CategoryPictureUrl(object url)
        {
            return string.Concat("/images/", url);
        }

        public static string VisitThumbnailUrl(object url)
        {
            return string.Concat("http://autourdeaix.free.fr/photos/", url, ".gif").Replace(" ","%20");
        }

        public static string VisitPictureUrl(object url)
        {
            return string.Concat("http://autourdeaix.free.fr/photos/", url, ".jpg").Replace(" ", "%20");
        }
    }
}